/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package junchangmis.teacher;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.sql.ResultSet;
import publicmethod.*;

/**
 *
 * @author developers
 */
public class TeacherInputMethod {

    public static void addTeacher(teacher tea) {
        try {
            DbOperation db = new DbOperation();
            db.DbConnect();
            String sql = "insert into teacher values('" + tea.yearStart + "','" + tea.monthStart + "','" + tea.dayStart + "','" + tea.yearEnd + "','" + tea.monthEnd + "','" + tea.dayEnd + "','" + tea.week + "','" + tea.name + "','" + tea.classCode + "','" + tea.classCount + "','" + tea.listenCount + "','" + tea.sumStart + "','" + tea.sumEnd + "','" + tea.change + "','" + tea.stopCount + "','" + tea.shiftCount + "','" + tea.insteadCount + "','" + tea.addCount + "')";
            db.DBSqlExe(sql);
            db.DbClose();
        } catch (SQLException ex) {
            Logger.getLogger(TeacherInputMethod.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static boolean hasTeacher(teacher tea) {
        DbOperation db = new DbOperation();
        db.DbConnect();
        String sql = "select * from teacher where name='" + tea.name + "' and yearStart='" + tea.yearStart + "' and monthStart='" + tea.monthStart + "' and classCode='" + tea.classCode + "'";
        ResultSet rs = db.DBSqlQuery(sql);
        try {
            if (rs.next()) {
                return true;
            } else {
                return false;
            }
        } catch (SQLException ex) {
            Logger.getLogger(TeacherInputMethod.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
}
